/*
 * shift_register.h
 *
 *  Created on: Apr 24, 2024
 *      Author: wzx05
 */

#ifndef INC_RFSWCTRL_H_
#define INC_RFSWCTRL_H_

#include "stm32f1xx_hal.h"  // 包含HAL库的主头文件

//#define RFSW_Type EPX_SP6T_0C_18A_TC002
//#define RFSW_Position_Count 6
//#define Device_not_Found 1
//#define Postion_exceed_Limit 1
#define RFSW_Device_Count 4

typedef struct {
	uint16_t positionCount;
    uint16_t resetPattern;
    uint16_t idlePattern;
    uint16_t positionPattern[8];
    uint16_t resetPulseLength; // in ms, 0 to 65535
    uint16_t setPulseLength; // in ms, 0 to 65535
    uint16_t pulseInterval; // in ms, 0 to 65535
} RFSwitchCtrlInfo;

// 定义移位寄存器的GPIO配置
typedef struct {
    GPIO_TypeDef* ds_port;
    uint16_t ds_pin;
    GPIO_TypeDef* stcp_port;
    uint16_t stcp_pin;
    GPIO_TypeDef* shcp_port;
    uint16_t shcp_pin;
} RFSWCtrlPins;

// 射频开关参数信息
extern RFSwitchCtrlInfo rfSwitchCtrlInfo;

// 输出模式数据
extern RFSWCtrlPins rfswCtrlPins[RFSW_Device_Count];

extern uint8_t rfswCurrentPosition[RFSW_Device_Count];

// 16bit移位寄存器输出控制
void shiftOut(uint8_t group, uint16_t data);

// RF Switch初始化
void setRFSwitch(uint8_t device, uint16_t position);

// RF Switch移动到下一格
void toggleRFSwitchToNext(uint8_t device);

// RF Switch初始化
void initRFSwitch(void);

#endif /* INC_RFSWCTRL_H_ */
